// pages/tuichu/tuichu.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    birthday: "",
    mydisabled: true,
    username: '',
    user: '',
    zhuangtai:"",
    zhuangtaihou:''
  },
  getInputValue(e) {

    this.setData({
      user: e.detail.value
    })
    // console.log(this.data.user)
  },
  selectpicker(e) {
    this.setData({
      birthday: e.detail.value,
    })
    // console.log(this.data.birthday)
  },
  change() {
    this.setData({
      mydisabled: false,
    }),
      wx.showModal({
        title: '温馨提示',
        content: "现在可以开始修改了"
      })
  },
  changeall() {
    var userinfo = wx.getStorageSync('userinfo');
    userinfo.nickName = this.data.user;
    wx.setStorageSync('userinfo', userinfo);
    var date = wx.getStorageSync('date');
    date = this.data.birthday;
    wx.setStorageSync('date', date);
    // console.log(wx.getStorageSync('userinfo').nickName)
    if (this.data.user.length == 0) {
      wx.showToast({
        icon: 'none',
        title: '未修改昵称,当前昵称为空',
        duration: 2000,

      })
    }
    else {
      wx.showToast({
        title: '修改成功！',
        icon: 'none',
      })
      setTimeout(function () {
        wx.reLaunch({
          url: '/pages/mine/mine',
        })
      }, 2500);

    }
  },
  tuichudenglu(){
      wx.setStorageSync('userinfo', '')
      wx.setStorageSync('zhuangtai', false)

    setTimeout(function () {
      wx.reLaunch({
        url: '/pages/mine/mine',
      })
    }, 2000);

    wx.showToast({
      title: '退出成功！',
      icon:'none'
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      username: wx.getStorageSync('userinfo').nickName,
      birthday: wx.getStorageSync('date'),
      zhuangtai:wx.getStorageSync('zhuangtai'),
      zhuangtaihou:wx.getStorageSync('zhuangtaihou'),
      username:wx.getStorageSync('userinfo').nickName,
      touxiang:wx.getStorageSync('userinfo').avatarUrl
    })
    // this.setData({
    //   birthday: wx.getStorageSync('date')

    // })
    // this.setData({
    //   zhuangtai:wx.getStorageSync('zhuangtai'),
    //   zhuangtaihou:wx.getStorageSync('zhuangtaihou')
    // })
    // this.setData({
    //   username:wx.getStorageSync('userinfo').nickName
    // })
    // console.log(wx.getStorageSync('date'))
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})